home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-18 | 7.5 KB | 297 lines | [TEXT/IGR0] |
- | WMFitFunctions v1.1 - 11/1/93
- |
- | These functions were contributed or suggested by Igor users.
- | We have renamed them so that the last digit(s) is the number of coefficients.
- | For example, power_3 has three coefficients, w[0], w[1], and w[2].
- | When describing the equation, we use Kn for w[n] because it's a little easier to read.
- |
- | To use one of these functions, copy it and paste into your procedure window rather
- | than opening or #including this entire file; it will shorten your compile time a little.
-
- | POLYNOMIAL FUNCTIONS
- | y = K0 +K1*x (Use this to hold K0 or K1 constant; built-in line fit can't do that)
- Function/D lineHold_ff2(w,x)
- Wave/D w;Variable/D x
-
- return w[0]+w[1]*x
- End
-
- | y = K0 +K1*x + K2*x^2 (Use this to hold K0 … K2 constant; built-in poly fit can't do that)
- Function/D poly_ff3(w,x)
- Wave/D w;Variable/D x
-
- return w[0]+(w[1]+ w[2]*x)*x
- End
-
- | y = K0 +K1*x + K2*x^2 +K3*x^3 (Use this to hold K0 … K3 constant; built-in poly fit can't do that)
- Function/D poly_ff4(w,x)
- Wave/D w;Variable/D x
-
- return w[0]+(w[1]+(w[2]+w[3]*x)*x)*x
- End
-
- | y = K0 +K1*x + K2*x^2 +K3*x^3 +K4*x^4 (Use this to hold K0 … K4 constant; built-in poly fit can't do that)
- Function/D poly_ff5(w,x)
- Wave/D w;Variable/D x
-
- return w[0]+ (w[1]+ (w[2]+(w[3]+w[4]*x)*x)*x)*x
- End
-
-
- | EXPONENTIAL FUNCTIONS
-
- | y= K0 + x**K1, x > 0
- Function/D power_ff2(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + x^w[1]
- End
-
- | y= K0 + K1*x**K2, x > 0
- Function/D power_ff3(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*(x^w[2])
- End
- | y= K0 + K1**x
- Function/D k1RaisedX_ff2(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]^x
- End
-
- | y= K0 + K1**x
- Function/D k2RaisedX_3(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*w[2]^x
- End
-
- | y = K0 + K1*exp(x/K2) + K3*exp(x/K4), similar to dblexp
- Function/D dblexpInv_ff5(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*exp(x/w[2]) + w[3]*exp(x/w[4])
- End
-
- | LOGARITHMIC FUNCTIONS
-
-
- | y= K0 + K1*ln(x), x > 0
- Function/D ln_ff2(w,x) | NOT ln^2
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*ln(x)
- End
-
- | y= K0 + K1*log(x), x > 0
- Function/D logBaseTen_ff2(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*log(x)
- End
-
- | y= K0 + K1*log2(x), x > 0
- Function/D logBaseTwo_ff2(w,x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*ln(x)/ln(2) | for a different base b, replace ln(2) with ln(b).
- End
-
-
- | SPECIAL-PURPOSE FUNCTIONS
- | The following functions are classified by what they are used for,
- | rather than their mathematical form.
-
- | GEOLOGIC FUNCTIONS
- | Dr. John D. Weeks
- | john_weeks@brown.edu
- | Here are two functions we have used in stress relaxation experiments
- | studying rock friction. In these experiments a load is applied, and the
- | loading piston is held at a constant position. Any creep of the sample
- | results in decaying stress as the (relatively) compliant loading piston
- | changes length. A particular function giving stress as a function of slip
- | velocity (stress = c1 + c2*ln(V)) yields a velocity decay described by a
- | hyperbola in time:
-
- | y = K0 /(K1+ x)
- Function/D hyperbola_ff2(w, x) | see also kin2ndOrder_3 function
- Wave/D w; Variable/D x
-
- return w[0]/(w[1] + x)
- End
-
- | This function also describes the decay of rate of aftershocks after an
- | earthquake. This is probably *not* a coincidence.
- |
- | This decay in velocity results in the following function for decay of
- | stress with time:
-
- | y = K0 + K1*ln(K2+x)
- Function/D logplus_ff3(w,x) | NOT log+3
- Wave/D w; Variable/D x
-
- return w[0]+w[1]*ln(w[2]+x)
- End
-
- | KINETICS FUNCTIONS
- | wishart@bnl.bnl.gov (James Wishart)
- |
- | y = K0 + K1/(1+K2*x)
- Function/D kin2ndOrder_ff3(w, x)
- Wave/D w;Variable/D x
-
- return w[0] + w[1]/(1+w[2]*x)
- End
-
- | y = K0 + K1*exp(K2*x) + K3*exp(K4*x)
- Function/D KinTwo1stOrder_ff5(w, x) |Returns two first orders - this is similar to dblexp
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*exp(w[2]*x)+ w[3]*exp(w[4]*x)
- End
-
- | y = K0 + K1/(1+K2*x) + K3*exp(K4*x)
- Function/D Kin1st2ndOrder_ff5(w, x) |Returns second and first orders
- Wave/D w;Variable/D x
-
- return w[0] + w[1]/(1+w[2]*x)+ w[3]*exp(w[4]*x)
- End
-
- | y = K0 + K1*exp(K2*x) + K3*exp(K4*x) + K5*x
- Function/D KinTwo1stOrderSlope_ff6(w, x) |Returns two first orders plus slope
- Wave/D w;Variable/D x |Slope compensates for baseline drift or
- | a slow subsequent kinetic process
-
- return w[0] + w[1]*exp(w[2]*x)+ w[3]*exp(w[4]*x)+ w[5]*x
- End
-
- | y = K0 + K1*exp(K2*x) + K3*x
- Function/D Kin1stOrderSlope_ff4(w, x) |Returns first order plus slope
- Wave/D w;Variable/D x
-
- return w[0] + w[1]*exp(w[2]*x)+ w[3]*x
- End
-
- | y = K0 + K1/(1+K2*x) + K3*x
- Function/D Kin2ndOrderSlope_ff4(w, x) |Returns second order plus slope
- Wave/D w;Variable/D x
-
- return(w[0] + w[1]/(1+w[2]*x)+ w[3]*x )
- End
-
- | BIOLOGICAL/THERMODYNAMICS FUNCTIONS
- |
- | Szoke Sz, Belgium
- | "Szvke Sz." <szoke@geru.ucl.ac.be>
- | The following equations are used in water adsorption isotherms, etc.
- | their inverse (x = f(y)) could be used as growing functions of living things
- Function/D adsorpA_ff2(w, x)
- Wave/D w; Variable/D x
-
- return ln(ln(1/x) / w[1]) / ln(w[0])
- End
-
- Function/D adsorpB_ff2(w, x)
- Wave/D w; Variable/D x
-
- return((-w[1] / ln(x))^(1 / w[0]))
- End
-
- Function/D adsorpC_ff2(w, x)
- Wave/D w; Variable/D x
-
- return((-w[1] / ln(1 - x))^(1 / w[0]))
- End
-
- Function/D adsorpD_ff2(w, x)
- Wave/D w; Variable/D x
-
- return(w[0] * (x / (1 - x)) + w[1])
- End
-
- Function/D adsorpE_ff2(w, x)
- Wave/D w; Variable/D x
-
- return(w[0] / ln(x) + w[1])
- End
-
- Function/D adsorpF_ff2(w, x)
- Wave/D w; Variable/D x
-
- return(w[1] * (x / (1 - x))^w[0])
- End
-
- Function/D adsorpG_ff2(w, x)
- Wave/D w; Variable/D x
-
- return(w[1] - w[0] * ln(1 - x))
- End
-
- Function/D adsorpG_ff7(w, x)
- Wave/D w; Variable/D x
-
- return(w[1] + (w[2] + w[3] * x) * (tanh(w[4] * (x - w[5])) + w[6]))
- End
-
- | temperature sensors can give Kelvin temperature versus electrical resistance as :
- Function/D tempKelvinFromRes_ff4(w, Res)
- Wave/D w; Variable/D Res
-
- return(1/(w[0] + w[1] * (Log(Res)) + w[2] * (Log(Res))^2 + w[3] * (Log(Res))^3))
- End
-
- | SIGMOIDS
- | Basic power sigmoid
- | Alan Saul <SAUL@vms.cis.pitt.edu>
- Function/D Sigmoid_ff3(w,xx)
- Wave/D w | w[0] is saturation amplitude
- | w[1] is exponent, should be restricted
- | w[2] is x value at 50% of saturation
- Variable/D xx | xx could be lots of things, e.g. contrast
-
- Variable/D tmp
- tmp=w[2]^w[1]+xx^w[1]
- Return w[0]*xx^w[1]/tmp
- End
-
- | This tanh function is the solution to the differential equation x'=x(1-x).
- | It comes up in chemical waves or other such reaction-diffusion equations.
- | Alan Saul <SAUL@vms.cis.pitt.edu>
- Function tanh_ff3(w,xx)
- wave/D w | w[0] is saturation amplitude
- | w[1] is slope at 50% point
- | w[2] is x value at 50% of saturation
- variable/D xx | xx could be time, space, ...
-
- Return w[0]/(1+exp(-w[1]*(xx-w[2])))
- End
-
- | PEAK FUNCTIONS
- | Voigt Approximation
- | For w[4]==1, this is a Lorentzian, and for w[4] -> infinity it is a Gaussian.
- | (actually for w[4]>50, it is really close to a Gaussian already).
- | For this function, center = w[2]
- | Full Width at Half Maximum= 2*w[3]*sqrt((2^(1/w[4])-1)*w[4])
- | For a Gaussian, FWHM = 2*w[4]*sqrt(ln(2))
- | For a Lorentzian, FWHM = 2*sqrt(w[4])
- | zzt@ornl.gov (Jon Tischler)
- Function/D Pearson_ff5(w,x)
- Wave/D w; Variable/D x
-
- return w[0]+w[1] / ( 1 + (x-w[2])^2/w[4]/w[3]^2 )^w[4]
- End
-
- | Difference of Gaussians
- | Alan Saul <SAUL@vms.cis.pitt.edu>
- Function/D DoG_ff4(w,xx)
- Wave/D w | w[0] is center strength, w[1] is center width
- | w[2] is surround strength, w[3] surround width
- Variable/D xx | xx could be spatial position or a frequency
-
- Variable/D center,surround
- center=w[0]*exp(-0.5*(xx/w[1])^2)
- surround=w[2]*exp((-0.5*xx/w[3])^2)
- Return center-surround
- End
-